<template>
  <div class="container">
    <div class="content">
      <div class="top">
        <span class="text">{{ params.title }}</span>
        <div class="open_card">立即开通</div>
      </div>
      <div class="bottom" v-if="tableData.length">
        <div class="four_icon">
          <div class="boon_item" v-for="item in tableData" :key="item.id">
            <img class="image" :src="fileBaseUrl + item.iconUrl" />
            <span class="text">{{ item.rightsText }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { openCardBoonList } from "@/api/vip";
export default {
  props: {
    module: {
      type: Object,
    },
    fileBaseUrl: {
      type: String,
    },
  },
  data() {
    return {
      params: {},
      tableData: [],
    };
  },
  watch: {
    "module.biz.params": {
      handler(params) {
        if (params) {
          this.fetchData();
        }
      },
      deep: true,
      // immediate: true,
    },
  },
  mounted() {
    let params = this.module.biz?.params;
    params && this.fetchData();
  },
  methods: {
    fetchData() {
      const { params } = this.module.biz;
      typeof params === "string" ? (this.params = JSON.parse(params)) : (this.params = params);
      this.params?.ids?.length ? this.getOpenCardBoonList() : this.tableData = []
    },
    getOpenCardBoonList() {
      openCardBoonList({ idList: this.params.ids }).then((res) => {
        this.tableData = res.data.splice(0, 4);

      });
    },
  },
};
</script>



<style lang="scss" scoped>
.container {
  margin-top: 10px;
  width: 100%;

  .content {
    margin: 0 16px;
    border-radius: 4px;
    background-color: #fff;
    overflow: hidden;

    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 7px 15px;
      background: #ffb72f;
      color: #fff;
      .text {
        font-size: 14px;
      }
      .open_card {
        padding: 4.5px 11px;
        font-size: 11.5px;
        border: 1px solid #fff;
        border-radius: 10px;
      }
    }

    .bottom {
      height: 95px;
      background: #fff;
      display: flex;
      align-items: center;
      .four_icon {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        .boon_item {
          flex: 1;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          .image {
            height: 28px;
            width: 28px;
            margin-bottom: 11px;
          }
          .text {
            font-size: 13px;
          }
        }
      }
    }
  }
}
</style>
